package com.myorg.domain;

import java.util.ArrayList;
import java.util.List;

public class SearchResult {
	private List<Email> list;

	public List<Email> getList() {
		if (list == null) {
			list = new ArrayList<Email>();
		}
		return list;
	}

	public SearchResult setList(List<Email> list) {
		this.list = list;
		return this;
	}

	synchronized public void merge(SearchResult another) {
		if (another != null && another.getList() != null) {
			getList().addAll(another.getList());
		}
	}

	public SearchResult max(int max) {
		return new SearchResult().setList(getList().subList(0, Math.min(getList().size(), max)));
	}
}
